using Core;
using UnityEngine;

namespace LightingUtil
{
    public class LightSwitcherExample : GameSubsystem
    {
        [SerializeField] private LightingProfile onLightingProfile;
        [SerializeField] private LightingProfile offLightingProfile;
        [SerializeField] private GameObject onSceneLights;
        [SerializeField] private GameObject offSceneLights;

        private bool _isOn = true;

        public void SwitchLight(bool isOn)
        {
            if (_isOn == isOn)
                return;

            if (isOn)
            {
                LightmapSettings.lightmapsMode = onLightingProfile.LightmapsMode;
                LightmapSettings.lightmaps = onLightingProfile.LightmapData;
                LightmapSettings.lightProbes = onLightingProfile.LightProbes;
            }
            else
            {
                LightmapSettings.lightmapsMode = offLightingProfile.LightmapsMode;
                LightmapSettings.lightmaps = offLightingProfile.LightmapData;
                LightmapSettings.lightProbes = offLightingProfile.LightProbes;
            }

            onSceneLights.SetActive(isOn);
            offSceneLights.SetActive(!isOn);
            _isOn = isOn;
        }
    }
}